package com.vinci.webtrading.dao.config;

import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class HibernateUtil {

	private static final SessionFactory concreteSessionFactory;

	static {
		try {
			concreteSessionFactory = new AnnotationConfiguration().configure()
					.buildSessionFactory();
		} catch (Throwable ex) {
			System.out.println("HibernateUtil.enclosing_method()");
			System.out.println("Erreur de creation de la session Hibernate: "+ex);
			throw new ExceptionInInitializerError(ex);
		}
	}

	public static SessionFactory getSessionFactory() throws HibernateException {
		return concreteSessionFactory;
	}
}